package com.gin.no_gay_alliance.fragment.topic;

import android.view.View;
import android.widget.ImageButton;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.viewpager2.widget.ViewPager2;

import com.gin.nga.response.body.ThreadBody;
import com.gin.nga.response.field.Forum;
import com.gin.no_gay_alliance.customview.PagerButton;
import com.gin.no_gay_alliance.databinding.FragmentTopicListCommonBinding;

/**
 * 版面精华区
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/5 14:31
 **/
public class ForumRecommendFragment extends BaseTopicListFragment<FragmentTopicListCommonBinding> {
    /**
     * 提供布局文件中的Toolbar
     *
     * @return toolbar
     */
    @Nullable
    @Override
    protected Toolbar initToolbar() {
        return b.toolbar;
    }


    /**
     * 提供布局文件中的翻页按钮
     *
     * @return {@link PagerButton}
     */
    @NonNull
    @Override
    protected PagerButton initPagerButton() {
        return b.btnPager;
    }

    /**
     * 提供布局文件中的刷新按钮
     *
     * @return {@link ImageButton}
     */
    @NonNull
    @Override
    protected ImageButton initRefreshButton() {
        return b.btnRefresh;
    }

    /**
     * 提供布局文件中的 主题列表分页ViewPager2
     *
     * @return ViewPager2
     */
    @NonNull
    @Override
    protected ViewPager2 initViewPager2() {
        return b.vp2;
    }

    @Override
    protected void onCreateView() {
        super.onCreateView();
        // 隐藏发帖按钮
        b.btnPost.setVisibility(View.GONE);

        initAdapter(param);
    }

    /**
     * 主题列表分页的查询成功回调
     *
     * @param threadBody 响应结果
     */
    @Override
    protected void onSuccessTopicListRequest(ThreadBody threadBody) {
        super.onSuccessTopicListRequest(threadBody);

        Forum forum = threadBody.getForum();
        if (forum != null) {
            // 设置标题
            toolbar.setTitle("[精]" + forum.getForumName());
        }
    }

}
